





<!DOCTYPE html>
<html class="writer-html5" lang="zh-CN" >
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>tvm.target &mdash; tvm 0.8.dev1982 文档</title>
  

  
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/gallery.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/css/tlcpack_theme.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../../_static/tvm-logo-square.png"/>
  

  
  
  
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
        <script src="../../../_static/jquery.js"></script>
        <script src="../../../_static/underscore.js"></script>
        <script src="../../../_static/doctools.js"></script>
        <script src="../../../_static/translations.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    
    <script type="text/javascript" src="../../../_static/js/tlcpack_theme.js"></script>
    <link rel="index" title="索引" href="../../../genindex.html" />
    <link rel="search" title="搜索" href="../../../search.html" />
    <link rel="next" title="tvm.tir" href="tir.html" />
    <link rel="prev" title="tvm.ir" href="ir.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    
<header class="header">
    <div class="innercontainer">
      <div class="headerInner d-flex justify-content-between align-items-center">
          <div class="headerLogo">
               <a href="https://tvm.apache.org/"><img src=https://tvm.apache.org/assets/images/logo.svg alt="logo"></a>
          </div>

          <div id="headMenu" class="headerNav">
            <button type="button" id="closeHeadMenu" class="navCloseBtn"><img src="../../../_static/img/close-icon.svg" alt="Close"></button>
             <ul class="nav">
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/community>Community</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/download>Download</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/vta>VTA</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/blog>Blog</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvm.apache.org/docs>Docs</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmconf.org>Conference</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://github.com/apache/tvm/>Github</a>
                </li>
                <li class="nav-item">
                   <a class="nav-link" href=https://tvmchinese.github.io/declaration_zh_CN.html>About-Translators</a>
                </li>
             </ul>
               <div class="responsivetlcdropdown">
                 <button type="button" class="btn-link">
                   ASF
                 </button>
                 <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                 </ul>
               </div>
          </div>
            <div class="responsiveMenuIcon">
              <button type="button" id="menuBtn" class="btn-menu"><img src="../../../_static/img/menu-icon.svg" alt="Menu Icon"></button>
            </div>

            <div class="tlcDropdown">
              <div class="dropdown">
                <button type="button" class="btn-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                  ASF
                </button>
                <div class="dropdown-menu dropdown-menu-right">
                  <ul>
                     <li>
                       <a href=https://apache.org/>Apache Homepage</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/licenses/>License</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/sponsorship.html>Sponsorship</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/security/>Security</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/foundation/thanks.html>Thanks</a>
                     </li>
                     <li>
                       <a href=https://www.apache.org/events/current-event>Events</a>
                     </li>
                     <li>
                       <a href=https://www.zhihu.com/column/c_1429578595417563136>Zhihu</a>
                     </li>
                  </ul>
                </div>
              </div>
          </div>
       </div>
    </div>
 </header>
 
    <nav data-toggle="wy-nav-shift" class="wy-nav-side fixed">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../../index.html">
          

          
            
            <img src="../../../_static/tvm-logo-small.png" class="logo" alt="Logo"/>
          
          </a>

          
            
            
                <div class="version">
                  0.8.dev1982
                </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption" role="heading"><span class="caption-text">如何开始</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../install/index.html">安装 TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../contribute/index.html">贡献者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">用户引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../tutorial/index.html">User Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../how_to/index.html">How To Guides</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">开发者引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/tutorial/index.html">Developer Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../dev/how_to/how_to.html">开发者指南</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">架构指南</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../arch/index.html">Design and Architecture</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">主题引导</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../topic/microtvm/index.html">microTVM：裸机使用TVM</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../topic/vta/index.html">VTA: Versatile Tensor Accelerator</a></li>
</ul>
<p class="caption" role="heading"><span class="caption-text">参考指南</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../langref/index.html">语言参考</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Python API</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="runtime.html">tvm.runtime</a></li>
<li class="toctree-l2"><a class="reference internal" href="ndarray.html">tvm.runtime.ndarray</a></li>
<li class="toctree-l2"><a class="reference internal" href="error.html">tvm.error</a></li>
<li class="toctree-l2"><a class="reference internal" href="ir.html">tvm.ir</a></li>
<li class="toctree-l2"><a class="reference internal" href="ir.html#module-tvm.instrument">tvm.instrument</a></li>
<li class="toctree-l2"><a class="reference internal" href="ir.html#module-tvm.transform">tvm.transform</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">tvm.target</a></li>
<li class="toctree-l2"><a class="reference internal" href="tir.html">tvm.tir</a></li>
<li class="toctree-l2"><a class="reference internal" href="tir.html#module-tvm.tir.transform">tvm.tir.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="tir.html#tvm-tir-analysis">tvm.tir.analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="tir.html#module-tvm.tir.stmt_functor">tvm.tir.stmt_functor</a></li>
<li class="toctree-l2"><a class="reference internal" href="te.html">tvm.te</a></li>
<li class="toctree-l2"><a class="reference internal" href="te.html#module-tvm.te.hybrid">tvm.te.hybrid</a></li>
<li class="toctree-l2"><a class="reference internal" href="driver.html">tvm.driver</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/index.html">tvm.relay</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/frontend.html">tvm.relay.frontend</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/nn.html">tvm.relay.nn</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/vision.html">tvm.relay.vision</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/image.html">tvm.relay.image</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/transform.html">tvm.relay.transform</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/analysis.html">tvm.relay.analysis</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/backend.html">tvm.relay.backend</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/dataflow_pattern.html">tvm.relay.dataflow_pattern</a></li>
<li class="toctree-l2"><a class="reference internal" href="relay/testing.html">tvm.relay.testing</a></li>
<li class="toctree-l2"><a class="reference internal" href="autotvm.html">tvm.autotvm</a></li>
<li class="toctree-l2"><a class="reference internal" href="auto_scheduler.html">tvm.auto_scheduler</a></li>
<li class="toctree-l2"><a class="reference internal" href="rpc.html">tvm.rpc</a></li>
<li class="toctree-l2"><a class="reference internal" href="micro.html">tvm.micro</a></li>
<li class="toctree-l2"><a class="reference internal" href="contrib.html">tvm.contrib</a></li>
<li class="toctree-l2"><a class="reference internal" href="graph_executor.html">tvm.contrib.graph_executor</a></li>
<li class="toctree-l2"><a class="reference internal" href="topi.html">tvm.topi</a></li>
<li class="toctree-l2"><a class="reference internal" href="vta/index.html">vta</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../links.html">Other APIs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../publications.html">Publications</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../genindex.html">索引</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
      
      <nav class="wy-nav-top" aria-label="top navigation" data-toggle="wy-nav-top">
        
            <div class="togglemenu">

            </div>
            <div class="nav-content">
              <!-- tvm -->
              Table of content
            </div>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        

          




















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../index.html">Docs</a> <span class="br-arrow">></span></li>
        
          <li><a href="index.html">Python API</a> <span class="br-arrow">></span></li>
        
      <li>tvm.target</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../../../_sources/reference/api/python/target.rst.txt" rel="nofollow"> <img src="../../../_static//img/source.svg" alt="viewsource"/></a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="module-tvm.target">
<span id="tvm-target"></span><h1>tvm.target<a class="headerlink" href="#module-tvm.target" title="永久链接至标题">¶</a></h1>
<p>Target description and codgen module.</p>
<p>TVM’s target string is in format <code class="docutils literal notranslate"><span class="pre">&lt;target_kind&gt;</span> <span class="pre">[-option=value]...</span></code>.</p>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>The list of options include:</p>
<ul>
<li><p><strong>-device=&lt;device name&gt;</strong></p>
<blockquote>
<div><p>The device name.</p>
</div></blockquote>
</li>
<li><p><strong>-mtriple=&lt;target triple&gt;</strong></p>
<blockquote>
<div><p>Specify the target triple, which is useful for cross
compilation.</p>
</div></blockquote>
</li>
<li><p><strong>-mcpu=&lt;cpuname&gt;</strong></p>
<blockquote>
<div><p>Specify a specific chip in the current architecture to
generate code for. By default this is infered from the
target triple and autodetected to the current architecture.</p>
</div></blockquote>
</li>
<li><p><strong>-mattr=a1,+a2,-a3,…</strong></p>
<blockquote>
<div><p>Override or control specific attributes of the target,
such as whether SIMD operations are enabled or not. The
default set of attributes is set by the current CPU.</p>
</div></blockquote>
</li>
<li><p><strong>-mabi=&lt;abi&gt;</strong></p>
<blockquote>
<div><p>Generate code for the specified ABI, for example “lp64d”.</p>
</div></blockquote>
</li>
<li><p><strong>-system-lib</strong></p>
<blockquote>
<div><p>Build TVM system library module. System lib is a global module that contains
self registered functions in program startup. User can get the module using
<a class="reference internal" href="runtime.html#tvm.runtime.system_lib" title="tvm.runtime.system_lib"><code class="xref any py py-func docutils literal notranslate"><span class="pre">tvm.runtime.system_lib</span></code></a>.
It is useful in environments where dynamic loading api like dlopen is banned.
The system lib will be available as long as the result code is linked by the program.</p>
</div></blockquote>
</li>
</ul>
<p>We can use <a class="reference internal" href="#tvm.target.Target" title="tvm.target.Target"><code class="xref py py-func docutils literal notranslate"><span class="pre">tvm.target.Target()</span></code></a> to create a tvm.target.Target from the target string.
We can also use other specific function in this module to create specific targets.</p>
</div>
<p><strong>类：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.target.Target" title="tvm.target.Target"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Target</span></code></a>(target[, host])</p></td>
<td><p>Target device information, use through TVM API.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.target.GenericFunc" title="tvm.target.GenericFunc"><code class="xref py py-obj docutils literal notranslate"><span class="pre">GenericFunc</span></code></a>()</p></td>
<td><p>GenericFunc node reference.</p></td>
</tr>
</tbody>
</table>
<p><strong>函数：</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.target.create" title="tvm.target.create"><code class="xref py py-obj docutils literal notranslate"><span class="pre">create</span></code></a>(target)</p></td>
<td><p>Deprecated.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.target.cuda" title="tvm.target.cuda"><code class="xref py py-obj docutils literal notranslate"><span class="pre">cuda</span></code></a>([model, options])</p></td>
<td><p>Returns a cuda target.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.target.rocm" title="tvm.target.rocm"><code class="xref py py-obj docutils literal notranslate"><span class="pre">rocm</span></code></a>([model, options])</p></td>
<td><p>Returns a ROCM target.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.target.mali" title="tvm.target.mali"><code class="xref py py-obj docutils literal notranslate"><span class="pre">mali</span></code></a>([model, options])</p></td>
<td><p>Returns a ARM Mali GPU target.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.target.intel_graphics" title="tvm.target.intel_graphics"><code class="xref py py-obj docutils literal notranslate"><span class="pre">intel_graphics</span></code></a>([model, options])</p></td>
<td><p>Returns an Intel Graphics target.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.target.arm_cpu" title="tvm.target.arm_cpu"><code class="xref py py-obj docutils literal notranslate"><span class="pre">arm_cpu</span></code></a>([model, options])</p></td>
<td><p>Returns a ARM CPU target.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.target.rasp" title="tvm.target.rasp"><code class="xref py py-obj docutils literal notranslate"><span class="pre">rasp</span></code></a>([options])</p></td>
<td><p>Return a Raspberry 3b target.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.target.bifrost" title="tvm.target.bifrost"><code class="xref py py-obj docutils literal notranslate"><span class="pre">bifrost</span></code></a>([model, options])</p></td>
<td><p>Return an ARM Mali GPU target (Bifrost architecture).</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.target.riscv_cpu" title="tvm.target.riscv_cpu"><code class="xref py py-obj docutils literal notranslate"><span class="pre">riscv_cpu</span></code></a>([model, options])</p></td>
<td><p>Returns a RISC-V CPU target.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.target.hexagon" title="tvm.target.hexagon"><code class="xref py py-obj docutils literal notranslate"><span class="pre">hexagon</span></code></a>([cpu_ver])</p></td>
<td><p>Returns a Hexagon target.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.target.list_tags" title="tvm.target.list_tags"><code class="xref py py-obj docutils literal notranslate"><span class="pre">list_tags</span></code></a>()</p></td>
<td><p>Returns a dict of tags, which maps each tag name to its corresponding target.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.target.generic_func" title="tvm.target.generic_func"><code class="xref py py-obj docutils literal notranslate"><span class="pre">generic_func</span></code></a>(fdefault)</p></td>
<td><p>Wrap a target generic function.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.target.get_native_generic_func" title="tvm.target.get_native_generic_func"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_native_generic_func</span></code></a>(name)</p></td>
<td><p>Get a generic function from the global registry.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.target.override_native_generic_func" title="tvm.target.override_native_generic_func"><code class="xref py py-obj docutils literal notranslate"><span class="pre">override_native_generic_func</span></code></a>(func_name)</p></td>
<td><p>Override a generic function defined in C++</p></td>
</tr>
</tbody>
</table>
<dl class="py class">
<dt class="sig sig-object py" id="tvm.target.Target">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.target.</span></span><span class="sig-name descname"><span class="pre">Target</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">target</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">host</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.Target" title="永久链接至目标">¶</a></dt>
<dd><p>Target device information, use through TVM API.</p>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>You can create target using the constructor or the following functions</p>
<ul class="simple">
<li><p><a class="reference internal" href="#tvm.target.arm_cpu" title="tvm.target.arm_cpu"><code class="xref py py-func docutils literal notranslate"><span class="pre">tvm.target.arm_cpu()</span></code></a> create arm_cpu target</p></li>
<li><p><a class="reference internal" href="#tvm.target.cuda" title="tvm.target.cuda"><code class="xref py py-func docutils literal notranslate"><span class="pre">tvm.target.cuda()</span></code></a> create CUDA target</p></li>
<li><p><a class="reference internal" href="#tvm.target.rocm" title="tvm.target.rocm"><code class="xref py py-func docutils literal notranslate"><span class="pre">tvm.target.rocm()</span></code></a> create ROCM target</p></li>
<li><p><a class="reference internal" href="#tvm.target.mali" title="tvm.target.mali"><code class="xref py py-func docutils literal notranslate"><span class="pre">tvm.target.mali()</span></code></a> create Mali target</p></li>
<li><p><a class="reference internal" href="#tvm.target.intel_graphics" title="tvm.target.intel_graphics"><code class="xref py py-func docutils literal notranslate"><span class="pre">tvm.target.intel_graphics()</span></code></a> create Intel Graphics target</p></li>
</ul>
</div>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.target.Target.current" title="tvm.target.Target.current"><code class="xref py py-obj docutils literal notranslate"><span class="pre">current</span></code></a>([allow_none])</p></td>
<td><p>Returns the current target.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.target.Target.list_kinds" title="tvm.target.Target.list_kinds"><code class="xref py py-obj docutils literal notranslate"><span class="pre">list_kinds</span></code></a>()</p></td>
<td><p>Returns the list of available target names.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.target.Target.check_and_update_host_consist" title="tvm.target.Target.check_and_update_host_consist"><code class="xref py py-obj docutils literal notranslate"><span class="pre">check_and_update_host_consist</span></code></a>(target[, …])</p></td>
<td><p>A helper function that merges a legacy “target, target_host” pair, then returns the merged target and its host field.</p></td>
</tr>
</tbody>
</table>
<p><strong>Attributes:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.target.Target.model" title="tvm.target.Target.model"><code class="xref py py-obj docutils literal notranslate"><span class="pre">model</span></code></a></p></td>
<td><p>Returns model from the target if it exists.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.target.Target.mcpu" title="tvm.target.Target.mcpu"><code class="xref py py-obj docutils literal notranslate"><span class="pre">mcpu</span></code></a></p></td>
<td><p>Returns the mcpu from the target if it exists.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.target.Target.mattr" title="tvm.target.Target.mattr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">mattr</span></code></a></p></td>
<td><p>Returns the mattr from the target if it exists.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.target.Target.current">
<em class="property"><span class="pre">static</span> </em><span class="sig-name descname"><span class="pre">current</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">allow_none</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.Target.current" title="永久链接至目标">¶</a></dt>
<dd><p>Returns the current target.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>allow_none</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – Whether allow the current target to be none</p>
</dd>
<dt class="field-even">引发</dt>
<dd class="field-even"><p><strong>ValueError if current target is not set.</strong> – </p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tvm.target.Target.model">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">model</span></span><a class="headerlink" href="#tvm.target.Target.model" title="永久链接至目标">¶</a></dt>
<dd><p>Returns model from the target if it exists.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tvm.target.Target.mcpu">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">mcpu</span></span><a class="headerlink" href="#tvm.target.Target.mcpu" title="永久链接至目标">¶</a></dt>
<dd><p>Returns the mcpu from the target if it exists.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="tvm.target.Target.mattr">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">mattr</span></span><a class="headerlink" href="#tvm.target.Target.mattr" title="永久链接至目标">¶</a></dt>
<dd><p>Returns the mattr from the target if it exists.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.target.Target.list_kinds">
<em class="property"><span class="pre">static</span> </em><span class="sig-name descname"><span class="pre">list_kinds</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.Target.list_kinds" title="永久链接至目标">¶</a></dt>
<dd><p>Returns the list of available target names.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.target.Target.check_and_update_host_consist">
<em class="property"><span class="pre">static</span> </em><span class="sig-name descname"><span class="pre">check_and_update_host_consist</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">target</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">host</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">target_is_dict_key</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.Target.check_and_update_host_consist" title="永久链接至目标">¶</a></dt>
<dd><p>A helper function that merges a legacy “target, target_host” pair, then returns
the merged target and its host field. The function is for legacy target and target
host pair only, and should not be used in the new target system.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>target</strong> (<em>Union</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict"><em>Dict</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference internal" href="tir.html#tvm.tir.Any" title="tvm.tir.Any"><em>Any</em></a><em>]</em><em>, </em><a class="reference internal" href="#tvm.target.Target" title="tvm.target.Target"><em>Target</em></a><em>]</em>) – The target or heterogeneous target</p></li>
<li><p><strong>host</strong> (<em>Union</em><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict"><em>Dict</em></a><em>[</em><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em>, </em><a class="reference internal" href="tir.html#tvm.tir.Any" title="tvm.tir.Any"><em>Any</em></a><em>]</em><em>, </em><a class="reference internal" href="#tvm.target.Target" title="tvm.target.Target"><em>Target</em></a><em>, </em><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.10)"><em>None</em></a><em>]</em>) – The target host</p></li>
<li><p><strong>target_is_dict_key</strong> (<em>Bool</em>) – When the type of target is dict, whether Target is the key (Otherwise the value)</p></li>
</ul>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.target.create">
<span class="sig-prename descclassname"><span class="pre">tvm.target.</span></span><span class="sig-name descname"><span class="pre">create</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">target</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.create" title="永久链接至目标">¶</a></dt>
<dd><p>Deprecated. Use the constructor of <a class="reference internal" href="#tvm.target.Target" title="tvm.target.Target"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tvm.target.Target</span></code></a> directly.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.target.cuda">
<span class="sig-prename descclassname"><span class="pre">tvm.target.</span></span><span class="sig-name descname"><span class="pre">cuda</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">model</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'unknown'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">options</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.cuda" title="永久链接至目标">¶</a></dt>
<dd><p>Returns a cuda target.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>model</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The model of cuda device (e.g. 1080ti)</p></li>
<li><p><strong>options</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><em>list of str</em>) – Additional options</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.target.rocm">
<span class="sig-prename descclassname"><span class="pre">tvm.target.</span></span><span class="sig-name descname"><span class="pre">rocm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">model</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'unknown'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">options</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.rocm" title="永久链接至目标">¶</a></dt>
<dd><p>Returns a ROCM target.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>model</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The model of this device</p></li>
<li><p><strong>options</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><em>list of str</em>) – Additional options</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.target.mali">
<span class="sig-prename descclassname"><span class="pre">tvm.target.</span></span><span class="sig-name descname"><span class="pre">mali</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">model</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'unknown'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">options</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.mali" title="永久链接至目标">¶</a></dt>
<dd><p>Returns a ARM Mali GPU target.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>model</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The model of this device</p></li>
<li><p><strong>options</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><em>list of str</em>) – Additional options</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.target.intel_graphics">
<span class="sig-prename descclassname"><span class="pre">tvm.target.</span></span><span class="sig-name descname"><span class="pre">intel_graphics</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">model</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'unknown'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">options</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.intel_graphics" title="永久链接至目标">¶</a></dt>
<dd><p>Returns an Intel Graphics target.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>model</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – The model of this device</p></li>
<li><p><strong>options</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><em>list of str</em>) – Additional options</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.target.arm_cpu">
<span class="sig-prename descclassname"><span class="pre">tvm.target.</span></span><span class="sig-name descname"><span class="pre">arm_cpu</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">model</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'unknown'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">options</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.arm_cpu" title="永久链接至目标">¶</a></dt>
<dd><p>Returns a ARM CPU target.
This function will also download pre-tuned op parameters when there is none.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>model</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – SoC name or phone name of the arm board.</p></li>
<li><p><strong>options</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><em>list of str</em>) – Additional options</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.target.rasp">
<span class="sig-prename descclassname"><span class="pre">tvm.target.</span></span><span class="sig-name descname"><span class="pre">rasp</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">options</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.rasp" title="永久链接至目标">¶</a></dt>
<dd><p>Return a Raspberry 3b target.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>options</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><em>list of str</em>) – Additional options</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.target.bifrost">
<span class="sig-prename descclassname"><span class="pre">tvm.target.</span></span><span class="sig-name descname"><span class="pre">bifrost</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">model</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'unknown'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">options</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.bifrost" title="永久链接至目标">¶</a></dt>
<dd><p>Return an ARM Mali GPU target (Bifrost architecture).</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>options</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><em>list of str</em>) – Additional options</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.target.riscv_cpu">
<span class="sig-prename descclassname"><span class="pre">tvm.target.</span></span><span class="sig-name descname"><span class="pre">riscv_cpu</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">model</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'sifive-u54'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">options</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.riscv_cpu" title="永久链接至目标">¶</a></dt>
<dd><p>Returns a RISC-V CPU target.
Default: sifive-u54 rv64gc</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>model</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a>) – CPU name.</p></li>
<li><p><strong>options</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><em>list of str</em>) – Additional options</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.target.hexagon">
<span class="sig-prename descclassname"><span class="pre">tvm.target.</span></span><span class="sig-name descname"><span class="pre">hexagon</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cpu_ver</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'v66'</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.hexagon" title="永久链接至目标">¶</a></dt>
<dd><p>Returns a Hexagon target.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>cpu_ver</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> (</em><em>default: &quot;v66&quot;</em><em>)</em>) – CPU version used for code generation. Not all allowed cpu str
will be valid, LLVM will throw an error.</p></li>
<li><p><strong>parameters</strong> (<em>Recognized keyword</em>) – </p></li>
<li><p><strong>-----------------------------</strong> – </p></li>
<li><p><strong>hvx</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.10)"><em>int</em></a><em> (</em><em>default: 128</em><em>)</em>) – Size of HVX vector in bytes. Value of 0 disables HVX codegen.</p></li>
<li><p><strong>sim_options</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><em>list of str</em><em> (</em><em>default: None</em><em>)</em>) – User defined sim arguments. CPU version defaults to cpu_ver.
Otherwise, separate versions are used for codegen and sim. Not
all allowed cpu strings will be valid, simulator will throw an
error if invalid. Does not affect codegen.</p></li>
<li><p><strong>llvm_options</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><em>list of str</em><em> (</em><em>default: None</em><em>)</em>) – User defined compiler arguments.</p></li>
<li><p><strong>link_params</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a><em> (</em><em>default: False</em><em>)</em>) – Whether to link graph parameters into the LLVM module.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.target.list_tags">
<span class="sig-prename descclassname"><span class="pre">tvm.target.</span></span><span class="sig-name descname"><span class="pre">list_tags</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">Dict</span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><span class="pre">str</span></a><span class="p"><span class="pre">,</span> </span><a class="reference internal" href="#tvm.target.Target" title="tvm.target.target.Target"><span class="pre">tvm.target.target.Target</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#tvm.target.list_tags" title="永久链接至目标">¶</a></dt>
<dd><p>Returns a dict of tags, which maps each tag name to its corresponding target.</p>
<dl class="field-list simple">
<dt class="field-odd">返回</dt>
<dd class="field-odd"><p><strong>tag_dict</strong> – The dict of tags mapping each tag name to to its corresponding target.
None if TVM is built in runtime-only mode.</p>
</dd>
<dt class="field-even">返回类型</dt>
<dd class="field-even"><p>Optional[<a class="reference internal" href="relay/dataflow_pattern.html#tvm.relay.dataflow_pattern.Dict" title="tvm.relay.dataflow_pattern.Dict">Dict</a>[<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)">str</a>, <a class="reference internal" href="#tvm.target.Target" title="tvm.target.Target">Target</a>]]</p>
</dd>
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="tvm.target.GenericFunc">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">tvm.target.</span></span><span class="sig-name descname"><span class="pre">GenericFunc</span></span><a class="headerlink" href="#tvm.target.GenericFunc" title="永久链接至目标">¶</a></dt>
<dd><p>GenericFunc node reference. This represents a generic function
that may be specialized for different targets. When this object is
called, a specialization is chosen based on the current target.</p>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>Do not construct an instance of this object, it should only ever be
used as a return value from calling into C++.</p>
</div>
<p><strong>Methods:</strong></p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#tvm.target.GenericFunc.set_default" title="tvm.target.GenericFunc.set_default"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_default</span></code></a>(func[, allow_override])</p></td>
<td><p>Set the default function to be used if no specializations match the current target.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#tvm.target.GenericFunc.register" title="tvm.target.GenericFunc.register"><code class="xref py py-obj docutils literal notranslate"><span class="pre">register</span></code></a>(func, key_list[, allow_override])</p></td>
<td><p>Register a specialization for this GenericFunc.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="tvm.target.GenericFunc.set_default">
<span class="sig-name descname"><span class="pre">set_default</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">allow_override</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.GenericFunc.set_default" title="永久链接至目标">¶</a></dt>
<dd><p>Set the default function to be used if no specializations match
the current target.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>func</strong> (<em>function</em>) – The default function</p></li>
<li><p><strong>allow_override</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a>) – Whether to allow the current default to be overridden</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="tvm.target.GenericFunc.register">
<span class="sig-name descname"><span class="pre">register</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">key_list</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">allow_override</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.GenericFunc.register" title="永久链接至目标">¶</a></dt>
<dd><p>Register a specialization for this GenericFunc.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>func</strong> (<em>function</em>) – The function to be registered.</p></li>
<li><p><strong>key</strong> (<a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.10)"><em>str</em></a><em> or </em><em>list of str</em>) – The key to be registered.</p></li>
<li><p><strong>allow_override</strong> (<a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(在 Python v3.10)"><em>bool</em></a><em>, </em><em>optional</em>) – Whether to allow existing keys to be overridden.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.target.generic_func">
<span class="sig-prename descclassname"><span class="pre">tvm.target.</span></span><span class="sig-name descname"><span class="pre">generic_func</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fdefault</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.generic_func" title="永久链接至目标">¶</a></dt>
<dd><p>Wrap a target generic function.</p>
<p>Generic function allows registration of further functions
that can be dispatched on current target context.
If no registered dispatch is matched, the fdefault will be called.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>fdefault</strong> (<em>function</em>) – The default function.</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>fgeneric</strong> – A wrapped generic function.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>function</p>
</dd>
</dl>
<p class="rubric">示例</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">tvm</span>
<span class="c1"># wrap function as target generic</span>
<span class="nd">@tvm.target.generic_func</span>
<span class="k">def</span> <span class="nf">my_func</span><span class="p">(</span><span class="n">a</span><span class="p">):</span>
    <span class="k">return</span> <span class="n">a</span> <span class="o">+</span> <span class="mi">1</span>
<span class="c1"># register specialization of my_func under target cuda</span>
<span class="nd">@my_func.register</span><span class="p">(</span><span class="s2">&quot;cuda&quot;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">my_func_cuda</span><span class="p">(</span><span class="n">a</span><span class="p">):</span>
    <span class="k">return</span> <span class="n">a</span> <span class="o">+</span> <span class="mi">2</span>
<span class="c1"># displays 3, because my_func is called</span>
<span class="k">print</span><span class="p">(</span><span class="n">my_func</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
<span class="c1"># displays 4, because my_func_cuda is called</span>
<span class="k">with</span> <span class="n">tvm</span><span class="o">.</span><span class="n">target</span><span class="o">.</span><span class="n">cuda</span><span class="p">():</span>
    <span class="k">print</span><span class="p">(</span><span class="n">my_func</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.target.get_native_generic_func">
<span class="sig-prename descclassname"><span class="pre">tvm.target.</span></span><span class="sig-name descname"><span class="pre">get_native_generic_func</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.get_native_generic_func" title="永久链接至目标">¶</a></dt>
<dd><p>Get a generic function from the global registry. If no
function is registered under the given name, a new generic
function is created.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>name</strong> (<em>string</em>) – The name of the generic function to get</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>func</strong> – The generic function for the given name</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p><a class="reference internal" href="#tvm.target.GenericFunc" title="tvm.target.GenericFunc">GenericFunc</a></p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="tvm.target.override_native_generic_func">
<span class="sig-prename descclassname"><span class="pre">tvm.target.</span></span><span class="sig-name descname"><span class="pre">override_native_generic_func</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">func_name</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#tvm.target.override_native_generic_func" title="永久链接至目标">¶</a></dt>
<dd><p>Override a generic function defined in C++</p>
<p>Generic function allows registration of further functions
that can be dispatched on current target context.
If no registered dispatch is matched, the fdefault will be called.</p>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><p><strong>func_name</strong> (<em>string</em>) – The name of the generic func to be overridden</p>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p><strong>fgeneric</strong> – A wrapped generic function.</p>
</dd>
<dt class="field-odd">返回类型</dt>
<dd class="field-odd"><p>function</p>
</dd>
</dl>
<p class="rubric">示例</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">tvm</span>
<span class="c1"># wrap function as target generic</span>
<span class="nd">@tvm.target.override_native_generic_func</span><span class="p">(</span><span class="s2">&quot;my_func&quot;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">my_func</span><span class="p">(</span><span class="n">a</span><span class="p">):</span>
    <span class="k">return</span> <span class="n">a</span> <span class="o">+</span> <span class="mi">1</span>
<span class="c1"># register specialization of my_func under target cuda</span>
<span class="nd">@my_func.register</span><span class="p">(</span><span class="s2">&quot;cuda&quot;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">my_func_cuda</span><span class="p">(</span><span class="n">a</span><span class="p">):</span>
    <span class="k">return</span> <span class="n">a</span> <span class="o">+</span> <span class="mi">2</span>
<span class="c1"># displays 3, because my_func is called</span>
<span class="k">print</span><span class="p">(</span><span class="n">my_func</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
<span class="c1"># displays 4, because my_func_cuda is called</span>
<span class="k">with</span> <span class="n">tvm</span><span class="o">.</span><span class="n">target</span><span class="o">.</span><span class="n">cuda</span><span class="p">():</span>
    <span class="k">print</span><span class="p">(</span><span class="n">my_func</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
</pre></div>
</div>
</dd></dl>

</div>


           </div>
           
          </div>
          

<footer>

    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="tir.html" class="btn btn-neutral float-right" title="tvm.tir" accesskey="n" rel="next">下一个 <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="ir.html" class="btn btn-neutral float-left" title="tvm.ir" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> 上一个</a>
      
    </div>

<div id="button" class="backtop"><img src="../../../_static//img/right.svg" alt="backtop"/> </div>
<section class="footerSec">
    <div class="footerHeader">
      <ul class="d-flex align-md-items-center justify-content-between flex-column flex-md-row">
        <li class="copywrite d-flex align-items-center">
          <h5 id="copy-right-info">© 2020 Apache Software Foundation | All right reserved</h5>
        </li>
      </ul>

    </div>

    <ul>
      <li class="footernote">Copyright © 2020 The Apache Software Foundation. Apache TVM, Apache, the Apache feather, and the Apache TVM project logo are either trademarks or registered trademarks of the Apache Software Foundation.</li>
    </ul>

</section>
</footer>
        </div>
      </div>

    </section>

  </div>
  

    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

  </body>
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
    <!-- Theme Analytics -->
    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-75982049-2', 'auto');
    ga('send', 'pageview');
    </script>

    
   

</body>
</html>